#pragma once
#include "Component.h"
#include "Batch3D.h"
#include <memory>

class VertexBuffer;
class ElementBuffer;
class Material;
class  Mesh : public Component
{

public:
	explicit Mesh(Context* context);
	~Mesh() override;

	virtual void GetBatch(std::vector<Batch3D>& batches);
	virtual std::string GetComponentName() { return "Mesh"; };

	void SetElementBuffer(std::shared_ptr<ElementBuffer> elem);
	void AddVertextAttribut(const VertextAttribut& attr);
	void SetMode(unsigned mode) { mode_ = mode; }
	void SetRang(unsigned start, unsigned count) {
		start_ = start;
		count_ = count;
	}
	void SetMaterial(std::shared_ptr<Material> mat);
	std::shared_ptr<Material> GetMaterial() { return material_; }

	virtual std::shared_ptr<Component> Clone();
private:
	std::vector<VertextAttribut> vertexAttributList_{};
	std::shared_ptr<ElementBuffer> elementBuffer_{};
	unsigned mode_{ 4 };
	unsigned count_{ 0 };
	unsigned start_{ 0 };
	std::shared_ptr<Material> material_{};
};
